//******************************************************************************
//this code is protected by the GNU affero GPLv3
//author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
//                        <digital.ragnarok AT gmail dot com>
//******************************************************************************
#include "globals.h"

static void obj_release(struct client *c,s32 shell_surface_slot)
{
    c->objs[shell_surface_slot].state=CLIENT_OBJ_INVALID;
    client_obj_unref(c,c->objs[shell_surface_slot].shell_surface.surface_slot);
}

s8 shell_surface_new_visible(struct client *c,u32 shell_surface_id,
                                                               s32 surface_slot)
{
  s8 r=LWL_OK;
  s32 free_slot=CLIENT_FIRST_VALID_ID;
  while(1){
    if(free_slot==CLIENT_OBJS_MAX){
      r=LWL_ERR;
      break;
    }
    if(c->objs[free_slot].state&CLIENT_OBJ_INVALID){
      c->objs[free_slot].state=CLIENT_OBJ_SHELL_SURFACE|CLIENT_OBJ_VISIBLE;
      c->objs[free_slot].release=obj_release;
      c->objs[free_slot].id=shell_surface_id;
      c->objs[free_slot].n=1;//the wire has a reference on it

      client_obj_ref(c,surface_slot);
      c->objs[free_slot].shell_surface.surface_slot=surface_slot;
      break;
    }
    ++free_slot;
  }
  return r;
}

s8 shell_surface_pong(struct client *c,s32 shell_surface_slot,u32 serial)
{
  (void)c;(void)shell_surface_slot;(void)serial;
  //XXX:not implemented
  //the ping should start a timer with a timerfd and the first event, the pong
  //or the timer timeout win.
  return 0;
}

s8 shell_surface_move(struct client *c,s32 shell_surface_slot,u32 seat_id,
                                                                     u32 serial)
{
  (void)c;(void)shell_surface_slot;(void)seat_id;(void)serial;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_resize(struct client *c,s32 shell_surface_slot,u32 seat_id,
                                                           u32 serial,u32 edges)
{
  (void)c;(void)shell_surface_slot;(void)seat_id;(void)serial;(void)edges;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_top_level(struct client *c,s32 shell_surface_slot)
{
  (void)c;(void)shell_surface_slot;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_transient(struct client *c,s32 shell_surface_slot,
                                    u32 parent_surface_id,s32 x,s32 y,u32 flags)
{
  (void)c;(void)shell_surface_slot;(void)parent_surface_id;(void)x;(void)y;
  (void)flags;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_full_screen(struct client *c,s32 shell_surface_slot,
                                         u32 method,u32 framerate,u32 output_id)
{
  (void)c;(void)shell_surface_slot;(void)method;(void)framerate;(void)output_id;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_popup(struct client *c,s32 shell_surface_slot,u32 seat_id,
                         u32 serial,u32 parent_surface_id,s32 x,s32 y,u32 flags)
{
  (void)c;(void)shell_surface_slot;(void)seat_id;(void)serial;
  (void)parent_surface_id;(void)x;(void)y;(void)flags;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_maximised(struct client *c,s32 shell_surface_slot,
                                                                  u32 output_id)
{
  (void)c;(void)shell_surface_slot;(void)output_id;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_title(struct client *c,s32 shell_surface_slot,void *title)
{
  (void)c;(void)shell_surface_slot;(void)title;
  //XXX:not implemented
  return 0;
}

s8 shell_surface_set_class(struct client *c,s32 shell_surface_slot,void *class)
{
  (void)c;(void)shell_surface_slot;(void)class;
  //XXX:not implemented
  return 0;
}
